import { defineStore } from 'pinia'
import { getWaitList } from '@/api/api.js'
export const appCurrentState = defineStore('currentState', {
  state: () => {
    return {
      userWaitList: [], // 待办列表
      downLoadProcessShow: false,// 下载任务列表弹窗
      downLoadCounts: 0  // 下载任务数量
    }
  },

  actions: {
    // 控制下载任务弹窗显隐
    TOOGLE_XZRW_DIALOG(flag) {
      this.downLoadProcessShow = flag
    },
    // 保存下载任务数量
    SET_XZRW_COUNT(val) {
      this.downLoadCounts = val
    },
    // 接口获取下载任务数据
    async SET_WAIT_LIST() {
      const res = await getWaitList();
      if (res.succeed && res.data.length > 0) {
        this.userWaitList = res.data
      } else {
        this.userWaitList = []
      }
    }

  },

  getters: {
    getWaitList: state => state.userWaitList,
    getDownLoadProcessShow: state => state.downLoadProcessShow,
    getDownLoadCounts: state => state.downLoadCounts
  }
})
